# -*- coding: utf-8 -*-
import yagmail
from django.shortcuts import render


def sendmail(request):  # 邮件发送
    to = request.POST.get('to')
    cc = request.POST.get('cc')
    subject = request.POST.get('subject')
    contents = request.POST.get('contents')
    yag = yagmail.SMTP(
        host='smtp.qq.com', user='469687182@qq.com',
        # password='ppbdsowziqnlbhha',
        password='fvbedowwypupcaea',
        # smtp_ssl = True
    )
    try:
        yag.send(
            to=to,
            cc=cc,
            subject=subject,
            contents=contents,
            attachments=r'E:/TestPlatform_Cz/InterfaceTestPlatform/report/TestReport.html',
        )
        print("邮件发送成功！")

    except BaseException as e:

        print(e,"Error: 发送邮件失败！")
    return render(request, 'Page/Send_Email.html')